package com.qjc.demo.strategyAndFactory.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 策略枚举类
 *
 * @ClassName: StrategyEnum
 * @Author: qjc
 * @Date: 2023/5/9 17:46
 */
@Getter
@AllArgsConstructor
public enum StrategyEnum {
    ONE_STRATEGY("one", "策略一"),
    TWO_STRATEGY("two", "策略二"),
    THREE_STRATEGY("three", "策略三"),
    FOUR_STRATEGY("four", "策略四"),
    ;

    private String code;
    private String value;

    public static Optional<StrategyEnum> getByCode(String code) {
        return Arrays.stream(StrategyEnum.values()).parallel()
                .filter(data -> data.getCode().equals(code)).findFirst();
    }

}
